package com.hdit.guimei.service.impl;

import com.hdit.guimei.domain.Announcement;
import com.hdit.guimei.mapper.AnnouncementMapper;
import com.hdit.guimei.service.AnnouncementService;
import net.sf.cglib.core.MethodWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 张宝玉
 * @date 2021/1/19 15:40
 */
@Service
public class AnnouncementServiceImpl implements AnnouncementService {
    @Autowired
    public AnnouncementMapper announcementMapper;

    @Override
    public List<Announcement> findannouncements() {
        List<Announcement> announcementList = announcementMapper.findannouncement();
        return announcementList;
    }

    @Override
    public int updateannouncement(int id,String title,String context) {
        Announcement announcement = new Announcement();
        announcement.setTitle(title);
        announcement.setContext(context);
        announcement.setId( id);
        int i = announcementMapper.updateannouncement(announcement);
        return i;
    }

    @Override
    public int updateannouncementstate(int id) {
        int i = announcementMapper.deleannouncement(id);
        return i;
    }

    @Override
    public int addannouncement(int id, String title, String context) {
        Announcement announcement = new Announcement();
        announcement.setId(id);
        announcement.setTitle(title);
        announcement.setContext(context);
        int i = announcementMapper.addannouncement(announcement);
        return i;
    }

}
